<template>
  <el-input
    v-model.trim="input"
    :disabled="disabled"
    :placeholder="placeholder || $t('search.placeholder')"
    v-on:keydown.enter="handleEnter"
  ></el-input>
</template>

<script setup lang="ts">
import i18n from '@/lang/index'
const $t = i18n.global.t
const props = defineProps({
    modelValue: {
        type: String,
        default: '',
    },
    placeholder: {
        type: String,
        default: '',
    },
    disabled: {
        type: Boolean,
        default: false,
    }
})
// const value = ref('')
const { modelValue, placeholder, disabled } = toRefs(props)
const emits = defineEmits(['update:modelValue','onEnter'])
let input: any = computed({
  get() {
    return modelValue?.value
  },
  set(val) {
    updateValue(val)
		// return val
  },
})
//   watch(value, (newV) => {
//     emits('update:modelValue', newV)
// })
const updateValue = (event) => {
    emits('update:modelValue', event);
}
const handleEnter = (event) => {
    emits('onEnter')
}
</script>

<style scoped></style>
